package com.wuhuahe.learning.multitable.mapper;

import com.wuhuahe.learning.multitable.pojo.Order;
import com.wuhuahe.learning.multitable.pojo.User;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface IOrderMapper {

    List<Order> findOrderWithUsers();


    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "orderTime", column = "orderTime"),
            @Result(property = "total", column = "total"),
            @Result(property = "user", column = "uid", javaType = User.class,
                    one = @One(select = "com.wuhuahe.learning.multitable.mapper.IUserMapper.selectUserById")),
    })
    @Select("select * from public.order")
    List<Order> findOrderWithUsersWitnAnnotation();

    @Select("select * from public.order where uid=#{uid}")
    Order selectOrderByUid(Integer uid);
}
